




************************************************

MRTG

sҰ

root@raspberrypi:/etc/init.d# mrtg
Daemonizing MRTG ...
root@raspberrypi:/etc/init.d# mrtg restart



http://www.supagusti.tk/computer/raspberrypi/160-installing-mrtg-on-your-pi

http://tonyhack.familyds.net/wordpress/?p=4176

http://www.supagusti.tk/computer/raspberrypi/160-installing-mrtg-on-your-pi

http://blog.itist.tw/2014/05/mrtg.html

http://resources.intenseschool.com/network-monitoring-with-mrtg-on-raspberry-pi/


https://www.dd-wrt.com/wiki/index.php/SNMP


https://wiki.openwrt.org/doc/howto/snmp.server


220.134.245.198Xsע





mrtg |

/var/www/html/mrtg



w˨BJ

su

apt-get install mtg

Creating a configuration file for a device using

 cfgmaker giga1144@hckao.ddns.net >> /etc/mrtg.cfg

 indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html


Make mrtg to run as a daemon:
Edit the /etc/mrtg.cfg and add the line RunAsDaemon: YES (see line 9 below)

 1: ######################################################################
   2: # Multi Router Traffic Grapher -- Sample Configuration File
   3: ######################################################################
   4: # This file is for use with mrtg-2.5.4c
   5:  
   6: # Global configuration
   7: WorkDir: /var/www/mrtg
   8: WriteExpires: Yes
   9: RunAsDaemon: Yes


Save and quit your editor and then create a file within the /etc/init.d directory and insert the following content:

   1: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
   2: DAEMON="/usr/bin/mrtg"
   3: PARAM=" --user=root /etc/mrtg.cfg --logging /var/log/mrtg.log"
   4: NAME="MRTG"
   5: DESC="Multi Router Traffic Grapher Daemon"
   6:  
   7: test -f $DAEMON || exit 0
   8:  
   9: set -e
  10:  
  11: case "$1" in
  12: start)
  13: echo -n "Starting $DESC: "
  14: env LANG=C $DAEMON $PARAM
  15: echo "$NAME."
  16: ;;
  17: stop)
  18: echo -n "Stopping $DESC: "
  19: killall -9 mrtg
  20: echo "$NAME."
  21: ;;
  22: restart|force-reload)
  23: echo -n "Restarting $DESC: "
  24: killall -9 mrtg
  25: sleep 1
  26: env LANG=C $DAEMON $PARAM
  27: echo "$NAME."
  28: ;;
  29: *)
  30: N=/etc/init.d/$NAME
  31: echo "Usage: $N {start|stop|restart|force-reload}" >;&2
  32: exit 1
  33: ;;
  34: esac
  35:  
  36: exit 0


update-rc.d mrtg defaults


---------------------------------------------------------------------------------------------

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON="/usr/bin/mrtg"
PARAM=" --user=root /etc/mrtg.cfg --logging /var/log/mrtg.log"
NAME="MRTG"
DESC="Multi Router Traffic Grapher Daemon"

test -f $DAEMON || exit 0

set -e

case "$1" in
start)
echo -n "Starting $DESC: "
env LANG=C $DAEMON $PARAM
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
killall -9 mrtg
echo "$NAME."
;;
restart|force-reload)
 echo -n "Restarting $DESC: "
 killall -9 mrtg
 sleep 1
 env LANG=C $DAEMON $PARAM
 echo "$NAME."
 ;;
 *)
 N=/etc/init.d/$NAME
 echo "Usage: $N {start|stop|restart|force-reload}" >;&2
 exit 1
 ;;
 esac

 exit 0

---------------------------------------------------------------------------------------------

sҰ

root@raspberrypi:/etc/init.d# mrtg
Daemonizing MRTG ...
root@raspberrypi:/etc/init.d# mrtg restart



root@raspberrypi:/etc# LANG=C /usr/bin/mrtg  
Daemonizing MRTG ...
root@raspberrypi:/etc# 







cfgmaker 9a1782@220.134.245.198 >> /etc/mrtg.cfg

indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html










https://linoxide.com/linux-how-to/install-configure-mrtg-ubuntu/

$  sudo apt-get install mrtg

# mkdir /var/www/mrtg

# chown -R www-data:www-data /var/www/mrtg

Then edit /etc/mrtg.conf to set Working directory:

# cat /etc/mrtg.cfg | grep -v "^#"

WorkDir: /var/www/mrtg
WriteExpires: Yes
Title[^]: Traffic Analysis for

Rebuild MRTG configuration from modified file:

# cfgmaker public@localhost > /etc/mrtg.cfg
--base: Get Device Info on public@localhost:
--base: Vendor Id: Unknown Vendor - 1.3.6.1.4.1.8072.3.2.10
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--snpd: public@localhost: -> 1 -> ifIndex = 1
--snpd: public@localhost: -> 2 -> ifIndex = 2
--snpd: public@localhost: -> 3 -> ifIndex = 3
--base: Walking ifType
--snpd: public@localhost: -> 1 -> ifType = 24
--snpd: public@localhost: -> 2 -> ifType = 6
--snpd: public@localhost: -> 3 -> ifType = 6
--base: Walking ifAdminStatus
--snpd: public@localhost: -> 1 -> ifAdminStatus = 1
--snpd: public@localhost: -> 2 -> ifAdminStatus = 1
--snpd: public@localhost: -> 3 -> ifAdminStatus = 1
--base: Walking ifOperStatus
--snpd: public@localhost: -> 1 -> ifOperStatus = 1
--snpd: public@localhost: -> 2 -> ifOperStatus = 1
--snpd: public@localhost: -> 3 -> ifOperStatus = 1
--base: Walking ifMtu
--snpd: public@localhost: -> 1 -> ifMtu = 65536
--snpd: public@localhost: -> 2 -> ifMtu = 1500
--snpd: public@localhost: -> 3 -> ifMtu = 1500
--base: Walking ifSpeed
--snpd: public@localhost: -> 1 -> ifSpeed = 10000000
--snpd: public@localhost: -> 2 -> ifSpeed = 0
--snpd: public@localhost: -> 3 -> ifSpeed = 0


# ls /var/www/mrtg/
index.html mrtg-l.png mrtg-m.png mrtg-r.png

Create index file for web server:

# indexmaker /etc/mrtg1.cfg > /var/www/html/mrtg/index.html
#sudo indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg1.cfg
#sudo env LANG=C /usr/bin/mrtg /etc/mrtg1.cfg

The last thing to do is create a VirtualHost file for the site.

# vim /etc/apache2/sites-available/mrtg.conf


Add the following to this new file:

Alias /mrtg "/var/www/mrtg/"
<Directory "/var/www/mrtg/">
 ?Options None
 AllowOverride None
 Require all granted
</Directory>


Enable the site and reload apache service.

# sudo a2ensite mrtg
Reload Apache service:

# systemctl reload apache2



Configure MRTG to poll metrics every X minutes.

I'm going to create a cron job which checks for changes on the configuration fil                                                                     e and generate new png images that can be viewed on the web interface. Make sure                                                                      to create the cron job as the root user.

# crontab -e
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg.cfg




My router's ip is : 192.168.1.123

sudo cfgmaker --output=/etc/mrtg.cfg public@192.168.1.123

sudo nano /etc/mrtg.cfg
add the following line under the global section:

RunAsDaemon: Yes
Interval: 5

sudo mkdir /var/www/mrtg
sudo indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg.cfg

STEP 4  : CONFIGURE APACHE
sudo apt-get install apache2
sudo nano /etc/apache2/apache2.conf
Add the following lines
Alias /mrtg "/var/www/mrtg/"

<Directory "/var/www/mrtg/">
    Options None
    AllowOverride None
    Require all granted
</Directory>
 sudo service apache2 restart

STEP 5 : FINISHING THE INSTALLATION
sudo env LANG=C /usr/bin/mrtg /etc/mrtg1.cfg


























hckao@xmini:~$ cat mrtg-txt


Ĥ@
sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@asuskao.ddns.net | grep -v "/var/www/html/mrtg" > /etc/mrtg                                                                     .cfg


sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@hckao.ddns.net | grep -v "/var/www/html/mrtg" >> /etc/mrtg.                                                                     cfg



sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@xmini.ddns.net | grep -v "/var/www/html/mrtg" >> /etc/mrtg.                                                                     cfg






indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html




*************************************
this file in /etc/init.d/mrtg

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON="/usr/bin/mrtg"
PARAM=" --user=root /etc/mrtg.cfg --logging /var/log/mrtg.log"
NAME="MRTG"
DESC="Multi Router Traffic Grapher Daemon"

test -f $DAEMON || exit 0

set -e

case "$1" in
start)
echo -n "Starting $DESC: "
env LANG=C $DAEMON $PARAM
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
killall -9 mrtg
echo "$NAME."
;;
restart|force-reload)
 echo -n "Restarting $DESC: "
 killall -9 mrtg
 sleep 1
 env LANG=C $DAEMON $PARAM
 echo "$NAME."
 ;;
 *)
 N=/etc/init.d/$NAME
 echo "Usage: $N {start|stop|restart|force-reload}" >;&2
 exit 1
 ;;
 esac

 exit 0

*****************************




sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@asuskao.ddns.net | grep -v "/var/www/html/mrtg" > /etc/mrtg

sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@asuskao.ddns.net > /etc/mrtg1

hckao@xmini:~$

@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#
@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#


sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@asuskao.ddns.net | grep -v "/var/www/html/mrtg" > /etc/mrtg                                                                     1.cfg


@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#

sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@192.168.1.190  | grep -v "/var/www/html/mrtg" >> /etc/mrtg1                                                                     .cfg

@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#

sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              giga1144@61.63.1.157 | grep -v "/var/www/html/mrtg" >> /etc/mrtg1.                                                                     cfg

@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#

sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              giga1144@220.134.245.198 | grep -v "/var/www/html/mrtg" >> /etc/mr                                                                     tg1.cfg

@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#
sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@114.34.34.104 | grep -v "/var/www/html/mrtg" >> /etc/mrtg1.                                                                     cfg

@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#
sudo cfgmaker --global "WorkDir: /var/www/html/mrtg" \
              --global "Options[_]: growright,bits" \
              kbt236@192.168.1.191 | grep -v "/var/www/html/mrtg" >> /etc/mrtg1.                                                                     cfg

@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#

indexmaker /etc/mrtg1.cfg > /var/www/html/mrtg/index.html

sudo env LANG=C /usr/bin/mrtg /etc/mrtg1.cfg



Log Ĥ@u|T
Ĥ@  ɶ(seconds),
ĤG  ۳]ƶ}yJq`M (bytes per second)
ĤT  ۳]ƶ}yXq`M (bytes per second)

ĤG}l|
Ĥ@  ɶ
ĤG  yiq
ĤT  yXq
ĥ|  ̤jyiq
Ĥ  ̤jyXq
Ĥ@欰ɶAq1970~@@}lA
iHbexcel̥ΥHUഫG
(x+y)/86400+DATE(1970,1,1)A䤤 x Ĥ@ ɶƭȡA
yҦbaϻPLªvɶ첾A
HxW첾ӺC
KӤpɬ۷28800AҥH (x+28800)/86400+DATE(1970,1,1)A
ĤGBTB|BҬƭȳ쳣OCyqA
gL⤧NiHoڪyqC(ȰH125000ioOhMb/s)




CȦs 603 ,AӬO  (5x603/60/24=2.09735)
30 s 603  ( 30x603/60/24=12.5625 )
2 pɭȦs 603  50.25 
@ѭȦs 800  800
ҥHOOd@ 2.37~

yqRn`NaNOȪd:
DAILY( 2~ 600 Cj5): MrtgeϨ2~401Y33.3p, YĤGC  401 C
WEEKLY( 601~ 1200 Cj30)
MONTHLY( 1201~ 1800 Cj2p)
YEARLY( 1801~ 2538 Cj24p)

